//
//  FHomePredictCell.m
//  LiveStar
//
//  Created by 漪珊 on 2017/4/10.
//  Copyright © 2017年 apple. All rights reserved.
//

#import "FHomePredictCell.h"
#import "PredictListModel.h"

@implementation FHomePredictCell

- (void)awakeFromNib {
    kButtonBorderRadius(self.subscribeBtn, 0, 0.5, HESHEX_COLOR(@"04DD98"));
    [super awakeFromNib];
}

- (void)setPredictModel:(PredictListModel *)predictModel {
    _predictModel = predictModel;
    [self.predictImgView sd_setImageWithURL:[NSURL URLWithString:predictModel.s_image] placeholderImage:kPLACE_MID];
    self.starName.text = predictModel.s_name;
    if ([predictModel.l_gift intValue]) {//有礼物
        self.presentTip.hidden = YES;
    } else {
        self.presentTip.hidden = NO;
    }
    
    if ([predictModel.l_package integerValue]) {//有红包
        self.redPaperTip.hidden = YES;
    } else {
        self.redPaperTip.hidden = NO;
    }
    [self.predictMembers setTitle:[NSString stringWithFormat:@"%@人预选",KString(predictModel.l_booked)] forState:UIControlStateNormal];
    NSString *dateStr = [NSString stringWithFormat:@"%@ %@",predictModel.l_date,predictModel.l_startime];
    NSDateFormatter *inputFormatter = [[NSDateFormatter alloc] init];
    [inputFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    NSDate* inputDate = [inputFormatter dateFromString:dateStr];
    [inputFormatter setDateFormat:@"yyyy年MM月dd日 HH:mm开播"];
    self.predictTime.text = [inputFormatter stringFromDate:inputDate];
    
    if ([predictModel.booked integerValue] == 20) {//未订阅
        [self.subscribeBtn setTitle:@"+ 订阅" forState:UIControlStateNormal];
        self.subscribeBtn.backgroundColor = HESHEX_COLOR(@"04DD98");
        [self.subscribeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    } else {//已订阅
        [self.subscribeBtn setTitle:@"已订阅" forState:UIControlStateNormal];
        self.subscribeBtn.backgroundColor = [UIColor whiteColor];
        [self.subscribeBtn setTitleColor:HESHEX_COLOR(@"04DD98") forState:UIControlStateNormal];
    }

}

//订阅直播
- (IBAction)subscribeAction:(id)sender {
    if (self.bookLive) {
        self.bookLive();
    }
}

@end
